﻿@{
    Layout = null;
}
@{
    if (ViewBag.respone != null)
    {
        @ViewBag.respone
    }
    else
    {
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>GET YOUR LOCATION</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
        <script type="text/javascript">


            function initialize() {
                // Auto Detect
                var timeoutVal = 10 * 1000 * 1000;
                navigator.geolocation.getCurrentPosition(
				displayPosition,
				displayError,
				{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
			);

            }

            function displayPosition(position) {
                // ALL Location in position.coords.latitude and position.coords.longtitude
                //alert('Latitude : ' + position.coords.latitude + ' Longtitude : ' + position.coords.longitude);

                $.ajax({
                    type: "POST",
                    url: "",
                    data: { lat: position.coords.latitude, long: position.coords.longitude, ID: @ViewBag.ID }
                }).done(function (msg) {
                   self.location = msg;
                });
            }

            function displayError(error) {
                var errors = {
                    1: 'Permission denied',
                    2: 'Position unavailable',
                    3: 'Request timeout'
                };
                alert("Error: " + errors[error.code]);
            }

        </script>
    </head>
    <body onload="initialize()">
    </body>
    </html>
    }
}
